package richbar.com.richbar.adapter.home;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.okhttp.GlideUtil;

import java.util.List;

import richbar.com.richbar.R;
import richbar.com.richbar.activity.product.ProductDetailsAc;
import richbar.com.richbar.bean.GoodsBean;
import richbar.com.richbar.util.NetWorkUtil;

/**
 * Created by QiYang on 2018/11/14.
 */

public class HomeLeftRightAdapter extends BaseQuickAdapter<GoodsBean> {
    public HomeLeftRightAdapter(int layoutResId, List<GoodsBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, final GoodsBean bean) {
        holder.setText(R.id.name,bean.getName());
        holder.setText(R.id.price,bean.getPrice());
        ImageView imageView = holder.getView(R.id.pic);
        GlideUtil.loadImage(mContext, NetWorkUtil.URL + bean.getPic(),imageView);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext,ProductDetailsAc.class);
                Bundle bundle = new Bundle();
                bundle.putString("id",bean.getId());
                bundle.putString("pic",bean.getPic());
                intent.putExtras(bundle);
                mContext.startActivity(intent);
            }
        });
    }
}
